package com.lanlian.commonlib.util;

import android.content.Context;

import com.lanlian.utillib.DateUtils;
import com.lanlian.utillib.MobileUtils;
import com.umeng.analytics.MobclickAgent;

import java.util.HashMap;
import java.util.Map;

/**
 * <pre>
 *     author : huxiaobo
 *     e-mail : huxiaobo@xlanlian.com
 *     date   : 2018/10/8 16:02
 *     desc   : 友盟统计
 *     version: 1.0
 * </pre>
 */
public class OnEventUtils {

    public static void onEvent(Context context, String eventId) {
        Map<String, String> maps = new HashMap<>();
        String device = MobileUtils.getSystemModel() + MobileUtils.getSystemVersion();
        String timeStr = DateUtils.longToString(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss");
        maps.put("device", device);
        maps.put("time", timeStr);
        maps.put("value", String.format("%s %s", device, timeStr));
        MobclickAgent.onEvent(context, eventId, maps);
    }

    public static void onEvent(Context context, String eventId, String value) {
        Map<String, String> maps = new HashMap<>();
        String device = MobileUtils.getSystemModel() + MobileUtils.getSystemVersion();
        String timeStr = DateUtils.longToString(System.currentTimeMillis(), "yyyy-MM-dd HH:mm:ss");
        maps.put("device", device);
        maps.put("time", timeStr);
        maps.put("value", String.format("%s %s %s", device, timeStr, value));
        MobclickAgent.onEvent(context, eventId, maps);
    }

}
